﻿using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using YJKRevitCode.ElmentSearchUtility.LinkDocumentSuite;
using SectionSignAndFilled.StairsRoomSection.DataDefine;
using SectionSignAndFilled.StairsRoomSection.Kit;
using SectionSignAndFilled.StairsRoomSection.Kit.CutLine;

namespace SectionSignAndFilled.StairsRoomSection.ElementPacket
{
	public class StairsObject : ElementObject
	{
		public StairsObject(BaseLinkDocumentResultBean LinkElem, SectionViewData secviewData = null) : base(LinkElem, secviewData)
		{
			this.m_objectType = ObjectType.kStairsType;
		}

		public override List<ElementObject> DividChild()
		{
			Stairs stairs = base.SelfElem.UseElement as Stairs;
			if (stairs == null)
			{
				return base.LstChildObj;
			}
			List<ElementId> list = stairs.GetStairsRuns().ToList<ElementId>();
			List<ElementId> list2 = stairs.GetStairsLandings().ToList<ElementId>();
			Document document = stairs.Document;
			foreach (ElementId elementId in list)
			{
				Element element = document.GetElement(elementId);
				BaseLinkDocumentResultBean linkElem = new BaseLinkDocumentResultBean(element, base.SelfElem.UseLinkeInstance, base.SelfElem.LstParentRevitLinkInstance);
				StairsRunObject stairsRunObject = new StairsRunObject(linkElem, base.SecViewData);
				StairsRunCutLineGetter cutLineBehavior = new StairsRunCutLineGetter();
				stairsRunObject.SetCutLineBehavior(cutLineBehavior);
				base.LstChildObj.Add(stairsRunObject);
			}
			foreach (ElementId elementId2 in list2)
			{
				Element element2 = document.GetElement(elementId2);
				BaseLinkDocumentResultBean linkElem2 = new BaseLinkDocumentResultBean(element2, base.SelfElem.UseLinkeInstance, base.SelfElem.LstParentRevitLinkInstance);
				StairsLandingObject stairsLandingObject = new StairsLandingObject(linkElem2, base.SecViewData);
				StairsLandingCutLineGetter cutLineBehavior2 = new StairsLandingCutLineGetter();
				stairsLandingObject.SetCutLineBehavior(cutLineBehavior2);
				base.LstChildObj.Add(stairsLandingObject);
			}
			return base.LstChildObj;
		}
	}
}
